package com.bitspilani.infonet.core;

import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;

import com.bitspilani.infonet.constants.GlobalConstants;

public class GPSLocationListner implements LocationListener{
	private static float accuracy;
	private static double lastKnownLatitude;
	private static double lastKnownLongitude;
	private static float lastKnownSpeed;



	public static float getLastKnownSpeed() {
		return lastKnownSpeed;
	}

	public static void setLastKnownSpeed(float lastKnownSpeed) {
		GPSLocationListner.lastKnownSpeed = lastKnownSpeed;
	}

	public static float getAccuracy() {
		return accuracy;
	}

	public static void setAccuracy(float accuracy) {
		GPSLocationListner.accuracy = accuracy;
	}

	public static double getlastKnownLatitude() {
		return lastKnownLatitude;
	}

	public static void setlastKnownLatitude(double lastKnownLatitude) {
		GPSLocationListner.lastKnownLatitude = lastKnownLatitude;
	}

	public static double getlastKnownLongitude() {
		return lastKnownLongitude;
	}

	public static void setlastKnownLongitude(double lastKnownLongitude) {
		GPSLocationListner.lastKnownLongitude = lastKnownLongitude;
	}

	@Override
	public void onLocationChanged(Location location) {
		setAccuracy(location.getAccuracy());
		setlastKnownLatitude(location.getLatitude());
		setlastKnownLongitude(location.getLongitude());
		setLastKnownSpeed(location.getSpeed()*GlobalConstants.MPS_TO_KMPH);//multiplying by constant to convert the speed from m/s to kmph
		
		
		System.out.println("accuracy: "+accuracy+", lastKnownLatitude: "+lastKnownLatitude
				+",lastKnownLongitude: "+lastKnownLongitude+", lastKnownSpeed: "+lastKnownSpeed);
	}

	@Override
	public void onProviderDisabled(String arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onProviderEnabled(String arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
		System.out.println("Status changed");

	}

}
